<style>
.fade.in {
    display: block;
}
.fade {
    display: none;
}
</style>
<div class="panel panel-default panel-intro">
    <div class="panel-heading">
        <div class="panel-lead"><em>{$row.name}</em>{$row.start_time}~{$row.end_time}</div>
		<ul class="nav nav-tabs">
		{foreach name="WeekModel" key="kk" item="vv"}
			<li  {if $active_fa == $kk}class="active" {/if}><a href="#{$kk}" data-toggle="tab" onclick="update_active_fa('{$kk}')">{:GetBaseInfo('Model')[$kk]}</a></li>
		{/foreach}
		</ul>
    </div>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
		{foreach name="WeekModel" key="kk"  item="vv"}
			<div class="tab-pane fade {if $active_fa == $kk}active in {/if}" id="{$kk}">
				<ul class="nav nav-tabs" >
				{foreach name="vv" key="key" item="vo" }
					<li  {if $active == $key}class="active" {/if}><a href="#{$kk}{$key}" data-toggle="tab" onclick="update_active('{$key}')">{:GetBaseInfo('Model')[$key]}</a></li>
				 {/foreach}
				</ul>
				{foreach name="vv" key="key" item="vo" }
				<div class="tab-pane fade {if $active == $key}active in {/if}" id="{$kk}{$key}">
					<div id="toolbar1" class="toolbar">
					<a href="javascript:;" class="btn btn-primary btn-refresh " onclick="load()" title="刷新"><i class="fa fa-refresh"></i> </a>
						{if isset($vo['add'])}
							<a href="javascript:;" class="btn btn-success btn-add" onclick="add({$id},'{$key}')" title="添加"><i class="fa fa-plus"></i> 添加</a>

						{/if}
						{if isset($vo['export'])}
							<a href="javascript:;" class="btn btn-success btn-export" onclick="analysis_export({$id},'{$key}')" title="导出"><i class="glyphicon glyphicon-export icon-share"></i> 导出</a>
						{/if}
						{if isset($vo['task'])}
							<a href="javascript:;" class="btn btn-danger  btn-task " onclick="task({$id},'{$key}')" title="发布任务"><i class="fa fa-recycle"></i> 发布任务</a>
						{/if}
					</div>
				   <?php include APP_PATH."/admin/view/".$vo['index'].".php";?>
				</div>
				{/foreach}
			</div>
		 {/foreach}

        </div>
    </div>
</div>

<script type="text/javascript">
	var active = '{$active}';
	var active_fa = '{$active_fa}';
	function add(id,type){
		var url_layer = 'finance/extract/week/public_add/id/'+id+'/type/'+type;
		Fast.api.open(url_layer,'添加记录');

	}
	function  analysis_export(id,type){
		var url_layer = '/admin/finance/extract/week/public_export/id/'+id+'/type/'+type;
		window.location.href=url_layer;

	}
	function edit(id,type,fa=''){
		if(fa){
			var url_layer = 'finance/extract/week/public_edit/id/'+id+'/type/'+type+'/fa/'+fa;
		}else{
			var url_layer = 'finance/extract/week/public_edit/id/'+id+'/type/'+type;
		}
		Fast.api.open(url_layer,'修改记录');
	}
	function view(id,type,day){
		var url_layer = 'finance/extract/week/view/ids/'+id+'/type/'+type+'/day/'+day;
		Fast.api.open(url_layer,'查看详情');
	}	
	function task(id,type,day){
		var url_layer = 'finance/extract/week/user_task/ids/'+id+'/type/'+type+'/day/'+day;
		Layer.confirm(
			__('User.Task_note'),
			{icon: 3, title: __('发布任务'), shadeClose: true},
			function (index) {
				Fast.api.ajax({
					url: url_layer,
				});
				Layer.close(index);
				/*setTimeout(function() {
					load();
				},2000);*/
			}
		);
		
	}
	function del(id,type){
		var url_layer = 'finance/extract/week/public_delete/id/'+id+'/type/'+type;
		 Layer.confirm(
			__('Are you sure you want to delete this item?'),
			{icon: 3, title: __('Warning'), shadeClose: true},
			function (index) {
				Fast.api.ajax({
					url: url_layer,
				});
				Layer.close(index);
				setTimeout(function() {
					load();
				},2000);
			}
		);
	}
	//修改默认页面
	function update_active(act){
		active = act;
	}
	//修改默认页面
	function update_active_fa(act){
		var lis = document.getElementById(act).childNodes.item(1).childNodes[1].lastChild.click();
	//	lis[1].lastChild.click();
		active_fa = act;
	}
	//加载
	function load(){
		var url = window.location.href;
		if(url.indexOf("&") != -1) url = url.substring(0, url.indexOf('&'));
		window.location.href = url+'&active='+active+'&active_fa='+active_fa;
	}


</script>